﻿//////////////////////////////////////////////////////////////////////////////
//
//  Copyright © 1998-2024 Glodon Company Limited.  All rights reserved.
//
//  Use of this software is subject to the terms of the Glodon license
//  agreement provided at the time of installation or download, or which
//  otherwise accompanies this software in either electronic or hard copy form.  
//
//////////////////////////////////////////////////////////////////////////////

#pragma once
#include "OwnerPtr.h"
#include "CollaborationCacheInterface.h"
namespace gcmp
{
    class IElementVersionManager;
    class IElementOwnerManager;
    class IElementEditPrivilegeManager;
    class IElementOccupantManager;
    class IElementRelationshipsVersionManager;

    /// \brief 协同缓存组件接口
    class COLLABORATION_CACHE_INTERFACE_EXPORT ICollaborationCacheComponent
    {
    public:
        /// \brief 获取实例
        static ICollaborationCacheComponent * Get();

        /// \brief 注册实例
        /// \param pImpl 正在注册的实现实例
        /// \return 老的实例
        static ICollaborationCacheComponent * Register(ICollaborationCacheComponent * pImpl);

        /// \brief 反注册实例
        static void Unregister();

    public:
        /// \brief 创建版本管理器。供文档使用
        virtual OwnerPtr<IElementVersionManager> CreateElementVersionManager() const = 0;

        /// \brief 创建所有者管理器。供文档使用
        virtual OwnerPtr<IElementOwnerManager> CreateElementOwnerManager() const = 0;

        /// \brief 创建编辑权限管理器。供文档使用
        virtual OwnerPtr<IElementEditPrivilegeManager> CreateElementEditPrivilegeManager() const = 0;

        /// \brief 创建占用着管理器。供文档使用
        virtual OwnerPtr<IElementOccupantManager> CreateElementOccupantManager() const = 0;

        /// \brief 创建构件强弱关系版本管理器。工文档使用
        virtual OwnerPtr<IElementRelationshipsVersionManager> CreateElementRelationshipsVersionManager() const = 0;

    public:
        /// \brief 根据用户id获取昵称
        virtual const wchar_t * GetNickname(int64_t userId) const = 0;

    private:
        /// \brief 工作的实例
        static ICollaborationCacheComponent * m_pImpl;
    };
}